package com.universalInterface.common.page;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * @author Lx
 * @date 2023/12/8 16:33
 * @description 分页条件
 */
@Data
@Schema(name = "PageCondition", description = "分页条件对象")
public class PageCondition implements Serializable {

	private static final long serialVersionUID = 3642327051671821L;

	/**
	 * 当前页是第几页
	 */
	@Schema(name = "pageNum", description = "当前页是第几页", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
	@Min(value = 1, message = "页码不小于1")
	@NotNull(message = "页码不小于1")
	protected Integer pageNum = 1;

	/**
	 * 每页多少条数据
	 */
	@Schema(name = "pageSize", description = "每页多少条数据(每页行数不能大于50)", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
	@Min(value = 1, message = "每页行数不小于10")
	@Max(value = 50, message = "每页行数不能大于50")
	@NotNull(message = "每页行数不小于10")
	protected Integer pageSize = 20;

	/**
	 * 排序方式 asc/desc
	 */
	@Schema(name = "order", description = "排序方式 asc/desc", example = "asc")
	private String order;

	/**
	 * 排序属性
	 */
	@Schema(name = "sort", description = "排序属性")
	private String sort;

}
